package com.pingan.glue.gluegame.aip.domain;

import com.pingan.glue.gluegame.common.Constant;
import com.pingan.glue.gluegame.entity.FaceFieldEntity;
import lombok.Data;

import java.util.List;

@Data
public class FaceFieldDto {

    private FieldValue expression; //表情
    private FieldValue face_shape; //脸型置信度
    private Double beauty;         //颜值
    private FieldValue gender;     //性别
    private FieldValue race;       //人种
    private EyeStatus eye_status;  //眼遮挡比例
    private Double face_probability;//人脸置信度，范围0-1
    private FaceQuality quality;    //人脸质量
    private FieldValue glasses;    //是否戴镜
    private FieldValue emotion;    //情绪
    private List<FaceMark> landmark72;
    private FieldValue face_type;  //脸类型 人脸 或卡通
    private FaceAngle angle;
    private String face_token;     //人脸唯一标识
    private FaceLocation location; //人脸在图片中的位置
    private List<FaceMark> landmark;//四个关键部位
    private Integer age;

    public FaceFieldEntity build(String path,Long userId){
        FaceFieldEntity entity = new FaceFieldEntity();
        entity.setUserId(userId);
        entity.setExpression(getExpression().getType()); //表情
        entity.setFaceShape(getFace_shape().getType());
        entity.setBeauty(getBeauty());
        entity.setGender(getGender().getType());
        entity.setRace(getRace().getType());
        entity.setFaceProbability(getFace_probability());
        entity.setGlasses(getGlasses().getType());
        entity.setEmotion(getEmotion().getType());
        entity.setFaceType(getFace_type().getType());
        entity.setFaceToken(getFace_token());
        entity.setFacePath(path);
        entity.setAge(getAge());
        //entity.setOccupation();
        //entity.setBloodType();
        //entity.setConstellation();
        //entity.setUpdateTime(new Date());
        //entity.setCreateTime(new Date());

        doSetGroupIdByGender(entity, entity.getGender());

        return entity;
    }

    private void doSetGroupIdByGender(FaceFieldEntity entity, String gender) {
        if (Constant.MALE.equals(gender)){
            entity.setGroupId(Constant.MALE_GROUP_ID_SUPPER_STAR);
        }else if(Constant.FEMALE.equals(entity.getGender())){
            entity.setGroupId(Constant.FEMALE_GROUP_ID_SUPPER_STAR);
        }else {
            entity.setGroupId(Constant.UNKNOWN_GROUP_ID_SUPPER_STAR);
        }
    }
}
